package com.yq.tanhua.ui

import android.os.Bundle
import android.view.View
import androidx.navigation.NavController
import androidx.navigation.NavDestination
import androidx.navigation.findNavController
import androidx.navigation.ui.setupWithNavController
import base.BaseActivity
import com.alibaba.android.arouter.facade.annotation.Route
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.gyf.immersionbar.ImmersionBar
import com.yq.tanhua.R
import com.yq.tanhua.im.ImFunction


import config.TanHua_main
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

/**
 *@time 2023/2/27 16:16
 *@author yangqing
 *@describe
 */
@Route(path = TanHua_main)
@AndroidEntryPoint
class TanHuaMainActivity : BaseActivity() {

    @Inject
    lateinit var imFunction: ImFunction
    override fun initLayout(): Int {
        return R.layout.tanhua_activity_main

    }

    override fun initView() {
        ImmersionBar.with(this).transparentBar().init()
        val navView = findViewById<BottomNavigationView>(R.id.nav_view)
        val navController = findNavController(R.id.nav_host_fragment_activity_main)
        navView.setupWithNavController(navController)
        navController.addOnDestinationChangedListener { controller, destination, arguments ->
            if (
                destination.id == R.id.navigation_recommend ||
                destination.id == R.id.navigation_friends ||
                destination.id == R.id.navigation_chat ||
                destination.id == R.id.navigation_mine
            ) {
                runOnUiThread { navView.visibility = View.VISIBLE }
            } else {
                runOnUiThread { navView.visibility = View.GONE }
            }
        }
    }

    override fun initData() {
        imFunction.testhilt()
        imFunction.preLoadData()
    }
}